import os


# 打印文件绝对路径
def getAbsFiles(path, filter=".txt"):
    """

    :param path: 路径
    :param filter: 过滤后缀名
    :return:
    """
    filterName = []
    for root, dirs, files in os.walk(path, topdown=True):
        for name in files:
            if name.find(filter) < 1:
                print(os.path.join(root, name))
                filterName.append(os.path.join(root, name))
    return filterName.reverse()

# 打印文件相对路径
def getCustomFiles(path,pathName = 'coin-eurpoe', filter=".txt"):
    '''
    得到pathName之后路径和文件名
    :param path: 源路径
    :param pathName: 删除名字及之前路径信息
    :param filter: 过滤后缀
    :return:
    '''
    filterName = []
    for root, dirs, files in os.walk(path, topdown=True):
        for name in files:
            if name.find(filter) < 1:
                # print(os.path.join(root, name))
                pathIndex = root.find(pathName)+len(pathName)+1
                # print(root.find(pathName)+len(pathName)+1)
                # print(os.path.join(root[pathIndex:], name))
                filterName.append(os.path.join(root[pathIndex:], name))
    filterName.sort()
    return filterName

print(getCustomFiles("/home/thseus/workspaces/flaskProject/mycoins/static/coin"
                "-eurpoe/"))
